package delegate

import kotlin.properties.Delegates
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty


class PDelegation(private var str: String) : ReadWriteProperty<Any?, String> {
    override fun getValue(thisRef: Any?, property: KProperty<*>): String {
        return str
    }

    override fun setValue(thisRef: Any?, property: KProperty<*>, value: String) {
        this.str = value
    }

}

class Test {
    var p: String by PDelegation("1")
    val q: String by lazy {
        "q"
    }
    val r: String by Delegates.notNull()
}

fun main(args: Array<String>) {
    val test = Test()
    println("p: ${test.p}")
    test.p = "2"
    println("p: ${test.p}")
    lazy {

    }



//    Delegates.notNull<String>()
}